package com.hnas.oracle.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.hnas.common.outdto.AnonyTransferRNameForm;
import com.hnas.common.outdto.CardInfoReceive;
import com.hnas.common.util.CommonReturn;
import com.hnas.common.util.PostServerInfoGet;
import com.hnas.common.util.ResultCode;
import com.hnas.oracle.dao.CommomOracleDao;

@Component("commonOracleService")
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
public class CommomOracleServiceImpl implements CommomOracleService{
	
	@Value("#{component['merchant_id']}") // 发卡商户id
	private String merchantId;
	
	@Autowired
	private PostServerInfoGet postServerInfoGet;
	
	@Autowired
	private CommomOracleDao commomOracleDao;

	@Override
	public String getOrganFullNameByEmpId(String empId) {
		return commomOracleDao.getOrganFullNameByEmpId(empId);
	}

	@Override
	public String getCardTypeByEmpId(String empId) {
		return commomOracleDao.getCardTypeByEmpId(empId);
	}

	@Override
	public boolean anonyTransferRNameByEmpId(String cardNo,CardInfoReceive cardInfo)throws Exception {
		AnonyTransferRNameForm form = new AnonyTransferRNameForm();
		form.setCardNo(cardNo);
		form.setCustName(cardInfo.getCustName());
		form.setCustSex(cardInfo.getCustSex());
		form.setIdentifyNo(cardInfo.getIdentifyNo());
		form.setIdentifyType(cardInfo.getIdentifyType());
		form.setMerchantId(merchantId);
		form.setPhoneNo(cardInfo.getPhoneNo());
		CommonReturn c = postServerInfoGet.getLatestValidEmpAndCard(form);
		if(ResultCode.SUCCESS.equals(c.getResultCode())){
			return true;
		}
		return false;
		
	}

	@Override
	public String getAccnoByCardNo(String cardNo, String subCode) {
		return commomOracleDao.getAccnoByCardNo(cardNo, subCode);
	}

}
